package com.itboye.lottery.dialog;

import android.content.Context;
import android.widget.Button;

import com.itboye.lottery.R;
import com.itboye.lottery.base.BaseDialog;
import com.itboye.lottery.view.calendarview.MyCalendarView;

import butterknife.BindView;
import butterknife.OnClick;

public class CalendarDialog extends BaseDialog {
    @BindView(R.id.btn_cancel)
    Button btn_cancel;
    @BindView(R.id.btn_ok)
    Button btn_ok;
    @BindView(R.id.dialog_clv)
    MyCalendarView dialog_clv;

    OnDateSelectedListener onDateSelectedListener;

    public OnDateSelectedListener getOnDateSelectedListener() {
        return onDateSelectedListener;
    }

    public void setOnDateSelectedListener(OnDateSelectedListener onDateSelectedListener) {
        this.onDateSelectedListener = onDateSelectedListener;
    }

    public CalendarDialog(Context context) {
        super(context);
    }

    private void initView() {
        setContentView(R.layout.dialog_calendarview);
        dialog_clv.setDate("2018-08-15");
//        dialog_clv.setOnDateSelectedListener((year, month, day) -> {
//
//        }
    }

    public CalendarDialog(Context context, boolean fromButton) {
        super(context, fromButton);
        initView();
    }




    @OnClick(R.id.btn_cancel)
    void close() {
        dismiss();
    }

    @OnClick(R.id.btn_ok)
    void sure() {
        if (getOnDateSelectedListener()!=null) {
            getOnDateSelectedListener().onDateSelected(dialog_clv.getmSelectYear(),dialog_clv.getmSelectMonth(),dialog_clv.getmSelectDay());
        }
        dismiss();
    }
    public interface OnDateSelectedListener {
        void onDateSelected(int year, int month, int day);
    }
}
